package com.agrm.stmq.service.impl;

import com.agrm.api.client.CartClient;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import java.util.List;

@RocketMQMessageListener(topic = "stmall-cart-topic",consumerGroup = "g1")
@Service
public class CartConsumerService implements RocketMQListener<List<Integer>> {

    private final CartClient cartClient;

    public CartConsumerService(CartClient cartClient) {
        this.cartClient = cartClient;
    }

    @Override
    public void onMessage(List<Integer> integers) {
        cartClient.deleteCartByIds(integers);
    }
}
